/**
 * 防抖
 *
 * @param {Function} func
 * @param {Number} delay
 * @returns Function
 */
export function useDebounce(func, delay = 1000) {
  let timer = null;
  return function () {
    timer && clearTimeout(timer);
    const arg = arguments;
    timer = setTimeout(() => {
      func.apply(this, arg);
      timer = null;
    }, delay);
  };
}
